package exception;

import io.jsonwebtoken.JwtException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import util.Result;

@ControllerAdvice
@ResponseBody
public class MyException {

    @ExceptionHandler({JwtException.class})
    public Object JwtException(Exception e){
        System.out.println("JwtException执行了："+e.getMessage());
        return new Result("10002","token无效");
    }

    @ExceptionHandler({
            Exception.class
    })
    public Object testException(Exception e){
        System.out.println("testException执行了："+e.getMessage());
        return new Result().fail();
    }
}
